package com.flute.framework.business;

import java.io.InputStream;

import com.flute.framework.configuration.ChecksumXMLConverter;
import com.flute.framework.data.impl.CheckSumHandler;
import com.flute.framework.exception.ConfigurationParseException;
import com.flute.tools.timer.FlexTimer;

public class TimerChecksum {
	private CheckSumHandler handler;
	private int startHour;
	private int startMinute;

	public int getStartHour() {
		return startHour;
	}

	public void setStartHour(int startHour) {
		this.startHour = startHour;
	}

	public int getStartMinute() {
		return startMinute;
	}

	public void setStartMinute(int startMinute) {
		this.startMinute = startMinute;
	}

	public CheckSumHandler getHandler() {
		return handler;
	}

	public void setHandler(CheckSumHandler handler) {
		this.handler = handler;
	}

	public void start() {
		FlexTimer.getInstance().startTimer(handler.getName(), handler,
				"checkSum", startHour, startMinute, Boolean.TRUE);
	}

	public void stop() {
		FlexTimer.getInstance().stopTimer(handler.getName());
	}

	public TimerChecksum(InputStream stream) throws ConfigurationParseException {
		TimerChecksum timerChecksumInfo = ChecksumXMLConverter
				.getTimerChecksumInfo(stream);
		this.handler = timerChecksumInfo.getHandler();
		this.startHour = timerChecksumInfo.startHour;
		this.startMinute = timerChecksumInfo.startMinute;
	}

}
